import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:sainbainu/common/models/response/group_list_response.dart';
import 'package:sainbainu/common/values/colors.dart';
import 'package:sainbainu/common/widgets/widget.dart';

const double itemHeight = 48;

class GroupItem extends StatelessWidget {
  final CroupItemResponse item;
  final Widget? rightChild;

  const GroupItem({
    super.key,
    required this.item,
    this.rightChild,
  });

  @override
  Widget build(BuildContext context) {
    return SizedBox(
      height: itemHeight,
      child: Row(
        children: [
          Hero(
            tag: '${item.uniqueTag}_${item.groupId}',
            child: ClipRRect(
              borderRadius: BorderRadius.circular(6),
              child: SizedBox(
                width: itemHeight,
                height: itemHeight,
                child: CustomImage(
                  url: item.cover ?? '',
                ),
              ),
            ),
          ),
          const SizedBox(width: 10),
          Expanded(
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                Text(
                  item.groupName ?? '',
                  maxLines: 1,
                  overflow: TextOverflow.ellipsis,
                  style: const TextStyle(
                    fontSize: 16,
                    color: AppColors.active,
                    fontWeight: FontWeight.w500,
                  ),
                ),
                Text(
                  '${item.memberNum ?? 0} 人已加入 · ${item.noteNum ?? 0} 帖子',
                  style: const TextStyle(
                    fontSize: 11,
                    color: AppColors.unactive,
                  ),
                ),
              ],
            ),
          ),
          if (rightChild != null) rightChild!,
        ],
      ),
    );
  }
}
